package com.kis.bot.utils.api

import java.util.*
import javax.script.ScriptEngineManager
import javax.script.ScriptException

/**
 * Created by wanglong on 16-8-31.
 */
infix fun String.getDomValue(key: String): String = this.split("<${key}>")[1].split("</${key}>")[0]

fun Date.getShortTime():Int{
    val ls = ScriptEngineManager()
    val engine = ls.getEngineByName("js")
    var shortTime =0
    try {
        shortTime = engine.eval("~ new Date()") as Int
    } catch (e: ScriptException) {
        e.printStackTrace()
    }
    return shortTime
}
fun String.getDeviceId()=this + (Date().time/1000L)